/** 
 * File-Name:Article.java
 *
 * Created on 2011-6-2 上午11:07:36
 * 
 * @author: Neo (neolimeng@gmail.com)
 * Software Engineering Institute, Peking University, China
 * 
 * Copyright (c) 2009, Peking University
 * 
 *
 */
package xiaoyou.entity;

import java.util.Date;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Description:
 * 
 * @author: Neo (neolimeng@gmail.com) Software Engineering Institute, Peking
 *          University, China
 * @version 1.0 2011-6-2 上午11:07:36
 */
public class Article {
	/**
	 * 工作动态
	 */
	public static final int NEWS = 1;
	/**
	 * 通知公告
	 */
	public static final int NOTICE = 2;
	/**
	 * 赤子情怀
	 */
	public static final int DONATOR_COMMENT = 3;
	/**
	 * 历年年鉴
	 */
	public static final int YEARLY_REPORT = 4;
	/**
	 * 基金会简介
	 */
	public static final int FOUNDATION_INTRO = 5;
	/**
	 * 组织机构
	 */
	public static final int ORGANIZATION = 6;
	/**
	 * 基金会章程
	 */
	public static final int FOUNDATION_PROCEDURES = 7;
	/**
	 * 管理办法
	 */
	public static final int ORGANIZATION_PROCEDURES = 8;
	/**
	 * 联系方式
	 */
	public static final int CONTACT_INFO = 9;
	/**
	 * 捐赠途径
	 */
	public static final int HOW_DONATION = 10;
	/**
	 * 捐赠流程
	 */
	public static final int DONATION_PROCEDURES = 11;
	/**
	 * 鸣谢办法
	 */
	public static final int THANKS = 12;
	/**
	 * 免税文件
	 */
	public static final int DUTY_FREE_DOC = 13;
	/**
	 * 下载专区
	 */
	public static final int DOWNLOAD = 14;
	/**
	 * 基金使用
	 */
	public static final int FUND_USAGE = 15;

	private long id;
	private String uuid = UUID.randomUUID().toString();
	private String title;
	private String content;
	private String imagePath;
	private String filePath;
	private long authorId;
	private User author;
	private int type = NEWS;
	private Date publishDate;
	private Date updateDate;
	private int entityStatus = 1;
	private String reserve01;
	private String reserve02;
	private String reserve03;
	private String reserve04;
	private String reserve05;

	public String getShortTitle() {
		String regex = "(<[^>]*>)";
		Matcher matcher = Pattern.compile(regex).matcher(title);
		String str = title;
		while (matcher.find()) {
			str = str.replace(matcher.group(0), "");
		}
		return str;
	}

	private String getShortTitle(int num) {
		String regex = "(<[^>]*>)";
		Matcher matcher = Pattern.compile(regex).matcher(title);
		String str = title;
		while (matcher.find()) {
			str = str.replace(matcher.group(0), "");
		}
		if (str != null & str.length() > num) {
			return str.substring(0, num) + "...";
		} else {
			return str;
		}
	}

	public String getShortTitle15() {
		return getShortTitle(15);
	}

	public String getShortTitle24() {
		return getShortTitle(24);
	}
	
	public String getShortTitle30() {
		return getShortTitle(30);
	}

	public String getShortContent() {
		String regex = "(<[^>]*>)";
		Matcher matcher = Pattern.compile(regex).matcher(content);
		String str = content;
		while (matcher.find()) {
			str = str.replace(matcher.group(0), "");
		}
		return str;
	}

	public String getShortContent(int num) {
		String regex = "(<[^>]*>)";
		Matcher matcher = Pattern.compile(regex).matcher(content);
		String str = content;
		while (matcher.find()) {
			str = str.replace(matcher.group(0), "");
		}
		if (str != null & str.length() > num) {
			return str.substring(0, num) + "...";
		} else {
			return str;
		}
	}

	public String getShortContent140() {
		return getShortContent(140);
	}

	public String getShortContent10() {
		return getShortContent(10);
	}

	/* Getters and Setters */
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public long getAuthorId() {
		return authorId;
	}

	public void setAuthorId(long authorId) {
		this.authorId = authorId;
	}

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
		this.authorId = author.getId();
	}

	public String getReserve01() {
		return reserve01;
	}

	public void setReserve01(String reserve01) {
		this.reserve01 = reserve01;
	}

	public String getReserve02() {
		return reserve02;
	}

	public void setReserve02(String reserve02) {
		this.reserve02 = reserve02;
	}

	public String getReserve03() {
		return reserve03;
	}

	public void setReserve03(String reserve03) {
		this.reserve03 = reserve03;
	}

	public String getReserve04() {
		return reserve04;
	}

	public void setReserve04(String reserve04) {
		this.reserve04 = reserve04;
	}

	public String getReserve05() {
		return reserve05;
	}

	public void setReserve05(String reserve05) {
		this.reserve05 = reserve05;
	}

	public Date getPublishDate() {
		return publishDate;
	}

	public void setPublishDate(Date publishDate) {
		this.publishDate = publishDate;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public int getEntityStatus() {
		return entityStatus;
	}

	public void setEntityStatus(int entityStatus) {
		this.entityStatus = entityStatus;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

	public String getImagePath() {
		return imagePath;
	}

	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}
}
